//
// Created by admin on 2017/9/9.
//
#pragma once
#include <iostream>
#include <string>
#include <regex>
#include <iterator>
#include <functional>
using namespace std;
class TestBase {
 public:
    TestBase(string fun):fun_(fun) {
        cout<<endl<<"------------------"<<fun_<<"-------------"<<endl;
    }
    virtual ~TestBase() {
        cout<<endl<<"------------------"<<fun_<<"-------------"<<endl;
    }
    string fun_;
};


#define TEST TestBase(__func__)

#define test(name) {\
    name test;\
    test.do_test();\
}

int fun(int a,int b) {
    return a+b;
}
class TestRegex :public TestBase {
public:
    typedef function<int ()> type;
    TestRegex() : TEST {}
    void do_test() {
        type f = std::bind(fun, 1,2);
        cout<<f()<<endl;
        test1();
    }
    void test1() {
        std::string s("1<color#>2</color>3");
        std::regex e("<color.*22");   // matches words beginning by "sub"
        std::string three=to_string(100);
        // using string/c-string (3) version:
        std::cout << std::regex_replace(s, e, to_string(100));
    }
};